//发布文章的路由模块
const express = require('express')
const router = express.Router()

//导入解析 formdata 表单格式数据的包
const multer = require('multer')
//导入路径处理模块
const path = require('path')

//创建 multer 实例对象 通过dest属性指定文件存放路径
const upload = multer({ dest: path.join(__dirname, '../uploads') })

//导入需要的处理函数模块
const article_handler = require('../router_handler/article')

// 导入验证数据的中间件
const expressJoi = require('@escook/express-joi')
//导入需要验证的规则对象
const { add_article_schema } = require('../schema/article')

//发布文章的路由
router.post('/add', upload.single('cover_img'), expressJoi(add_article_schema), article_handler.addArticle)


module.exports = router